package com.bdqn.factory;

import com.bdqn.dao.UserDao;
import com.bdqn.dao.UserDaoDB2Impl;
import com.bdqn.dao.UserDaoMySQLImpl;
import com.bdqn.dao.UserDaoOracleImpl;

/**
 * 简单工厂模式
 *
 * @author LILIBO
 * @since 2021-11-30
 */
public class SimpleDaoFactory {

    public static UserDao getInstance(String key) {
        UserDao userDao = null;
        switch (key) {
            case "mysql":
                userDao = new UserDaoMySQLImpl();
                break;
            case "oracle":
                userDao = new UserDaoOracleImpl();
                break;
            case "db2":
                userDao = new UserDaoDB2Impl();
                break;
            default:
                System.out.println("参数不合法，没有对应的实例可被创建");
                userDao = null;
                break;
        }
        return userDao;
    }
}
